package edu.cmich.cps.cps240.partyprincesspalace.hw06;

import java.awt.Graphics;
import java.awt.Point;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * An object which appears graphically on the workspace
 * @author holde1ja
 */
public interface WorkspaceObj {
	/*
	/**
	 * Tests if this WorkspaceObj has a connection to the given pin
	 * @param other A pin to see if we are connected to
	 * @return true if we are connected to the given pin, else false
	 */
	/*
	public boolean isConnected(Pin other);
	*/
	
	/**
	 * The WorkspaceObj draws a graphical representation of itself on
	 * the given graphical context, which should be the workspace's.
	 * @param g A graphics context that we are drawing to.
	 */
	public void draw(Graphics g);
	
	/**
	 * Attaches the specified pin, if possible
	 * @param ourPin A pin, which should be owned by this WorkspaceObj
	 * @param theirPin A pin, which should be owned by another WorkspaceObj
	 * @return true if the operation succeeded, else false
	 */
	//boolean attachTo(Pin ourPin, Pin theirPin);
	
	/**
	 * Detaches the two pins from each other, if possible.
	 * @param ourPin A pin (which should be owned by the current WorkspaceObj)
	 * @param theirPin A pin (which should not be owned by the current WorkspaceObj)
	 * @return true if the operation succeeded, else false
	 */
	//boolean detachFrom(Pin ourPin, Pin theirPin);
	
	/**
	 * Returns true if the provided location is "close" to the WorkspaceObj
	 * @param mouseClick a point which is in the same two-dimensional space
	 * 					as the WorkspaceObj
	 * @return true if the given location is close, else false
	 */
	public boolean isClose(Point mouseClick);
	
	/**
	 * Detaches all inputs and outputs in preperation of the WorkspaceObj
	 * being removed from the Workspace
	 */
	void remove();
	
	/**
	 * @return the name of the WorkspaceObj
	 */
	String getName();
	
	/**
	 * Changes the name of the WorkspaceObj
	 * @param name The new name of the WorkspaceObj
	 */
	void setName(String name);
	
	/**
	 * Is necessary for the Serializable implementation. Passes a serialized version of the object to the
	 * ObjectOutputStream passed in as a parameter.
	 * @param out, an ObjectOutputStream to which the serialized version of this object is passed.
	 */
	public void writeObject(ObjectOutputStream out) throws IOException;
	
	/**
	 * Is necessary for the Serializable implementation. Creates an object from the
	 * ObjectInputStream passed in as a parameter.
	 * @param in, an ObjectInputStream from which to create the object.
	 */
	public void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException;
}
